import asyncio
from controller import CRController
from agent import CRAgent

async def main():
    """
    代码审查系统使用示例
    """
    # 初始化控制器和Agent
    cr_controller = CRController()
    agent = CRAgent(cr_controller)
    
    try:
        # 运行审查任务
        result = await agent.run_review(
            repo="example/repo",
            pr_id="123",
            issue_id="456"
        )
        
        # 打印审查结果
        print("代码审查完成")
        print(f"状态: {result.status}")
        print("\n审查意见:")
        for comment in result.comments:
            print(f"- {comment}")
        print("\n改进建议:")
        for suggestion in result.suggestions:
            print(f"- {suggestion}")
            
    except Exception as e:
        print(f"审查过程中出现错误: {str(e)}")

if __name__ == "__main__":
    # 运行异步主函数
    asyncio.run(main())